package PrjHttpUtils

import (
	"dgo/goutils/httpfs"
	"dgo/goutils/utils"
	"net/http"
)

func StartWebRoot(pattern string, rootPath string) {
	http.Handle(pattern, http.StripPrefix(pattern, http.FileServer(http.Dir(rootPath))))
}

func StartDefaultWebRoot() {
	StartWebRoot("/", "webroot/")
}

func StartFileService(strPattern string, strPath string) {
	defer utils.PanicHandlerWithPrint()
	http.Handle(strPattern, http.StripPrefix(strPattern, httpfs.FileServer(http.Dir(strPath), 0, nil)))
}
